package cn.pet_know.controller;

import cn.pet_know.common.result.R;
import cn.pet_know.entity.dto.UserDTO;
import cn.pet_know.entity.vo.UserVO;
import cn.pet_know.service.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 注册用户
     * @param userDTO
     * @return
     */
    @PostMapping("/registryUser")
    public R<Boolean> registry(@RequestBody UserDTO userDTO) {
        return R.ok(userService.registry(userDTO));
    }

    /**
     * 查询用户信息
     * @param userDTO
     * @return
     */
    @PostMapping("/findUser")
    public R<UserVO> findUser(@RequestBody UserDTO userDTO) {
        return R.ok(userService.findUser(userDTO));
    }
    /**
     * 注销用户
     * @param userDTO
     * @return
     */
    @PostMapping("/goOutUser")
    public R<Boolean> goOutUser(@RequestBody UserDTO userDTO) {
        return R.ok(userService.goOutUser(userDTO));
    }
    /**
     * 修改用户信息
     * @param userDTO
     * @return
     */
    @PostMapping("/updateUser")
    public R<Boolean> updateUser(@RequestBody UserDTO userDTO) {
        return R.ok(userService.updateUser(userDTO));
    }

}